package co.yixiang.modules.shop.rest;

import co.yixiang.aop.log.Log;
import co.yixiang.modules.shop.service.YxInvestOrderService;
import co.yixiang.modules.shop.service.YxStoreProductService;
import co.yixiang.modules.shop.service.dto.KeepGoodsQueryCriteria;
import co.yixiang.modules.shop.service.dto.SubscribeGoodsQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author frq
 * @date 2020-06-24
 */
@Slf4j
@Api(tags = "认购商品管理")
@RestController
@RequestMapping("/api/subscribeGoods")
public class SubscribeGoodsController {
    @Autowired
    private YxInvestOrderService yxInvestOrderService;

    @Autowired
    private YxStoreProductService yxStoreProductService;


    @Log("查询已认购商品")
    @ApiOperation("查询已认购商品")
    @GetMapping("/findListSubscribeGoods")
    public ResponseEntity<Object> findListSubscribeGoods(SubscribeGoodsQueryCriteria criteria, Pageable pageable) {
        return new ResponseEntity<>(yxInvestOrderService.findListSubscribeGoods(criteria, pageable), HttpStatus.OK);
    }

    @Log("保留商品管理")
    @GetMapping("/findListKeepGoods")
    public ResponseEntity findListKeepGoods(KeepGoodsQueryCriteria criteria, Pageable pageable) {
        return new ResponseEntity<>(yxStoreProductService.findListKeepGoods(criteria, pageable), HttpStatus.OK);
    }
    @Log("释放商品")
    @GetMapping("/updateLockStatus/{id}")
    public ResponseEntity updateLockStatus(@PathVariable String id){
        return new ResponseEntity<>(yxStoreProductService.updateLockStatus(id,0), HttpStatus.OK);
    }
}